     <?php 
    //Tabs for Picks round
    require 'view/desktop/picks/PicksTab.php'; 
    ?>

    <?php 
    //Javescript for Picks
    require 'view/desktop/picks/SetPicksScript.php'; 
    ?>
    

    <?php
    //Print Data in each tab
    $sthTab = $this->model->GetRounds();
    $TabIndex = 0;
    while ($data = $sthTab->fetch()) {
        $RoundNr = $data['nr'];
        $RoundStatus = $data['roundStatus'];
        if (strcmp($RoundStatus, 'SetPicks') == 0) {
            $SetPicksEnabled = true;
        } else {
            $SetPicksEnabled = false;
        }



        $TabIndex++;
        ?>
        <div id="fragment-<?php echo $RoundNr ?>">
            <h3>Status: <?php echo $RoundStatus; ?> </h3>
            <table>
                <tr>
                    <td>
                        <div class="divPointsHeader">
                            <h3>Points</h3><img src="<?php echo URL ?>public/image/updown.png" alt=""/>
                        </div>
                    </td>
                    <td>
                        <div class="divMatchGroupHeader">
                            <h3>Match</h3><img src="<?php echo URL ?>public/image/mouse-cursor-icon.png" alt=""/> 
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>

                        <?php
                        require 'view/desktop/picks/SetPicksPriorityScript.php';
                        ?>



                        <ul class ="sortable" id="sortable_<?php echo $TabIndex; ?>">
                            <?php
                            //Get Priority for Points with extreme SQL statement
                            $sthPriority = $this->model->GetPriorityPoints($RoundNr, $_SESSION['memberId']);
                            while ($data = $sthPriority->fetch()) {
                                $points = $data['points'];
                                $priority = $data['priority'];
                                $color_index = $this->model->GetPicksStatus($data['picksResult'], $data['matchResult']);
                                if($color_index==-1)
                                    $color = "#DF0101";
                                if($color_index==0)
                                    $color = "#FFFFFF";
                                if($color_index==1)
                                    $color = "#3ADF00";
                                
                                    
                                
                                ?>
                                <li id="Round_<?php echo $RoundNr; ?>_Priority_<?php echo $priority; ?>">
                                    <div class="divPoints" style="background-color:<?php echo $color; ?>">
                                        <?php echo $points. PHP_EOL; ?>
                                    </div>
                                </li>
                                <?php
                            }
                            ?>    
                        </ul>
                    </td>

                    <td>
                        <ul class="unsortable" >
                            <?php
                            //Get Matchs in default priority            
                            $sthMatchs = $this->model->GetPicksInfo($RoundNr, $_SESSION['memberId']);
                            while ($data = $sthMatchs->fetch()) {
                                $PicksResult = $data['picksResult'];
                                $NameTeamA = $data['nameTeamA'];
                                $DisplayNameTeamA = $data['displayNameTeamA'];
                                $ImageTeamA = $data['imageNameTeamA'];
                                $NameTeamB = $data['nameTeamB'];
                                $DisplayNameTeamB = $data['displayNameTeamB'];
                                $ImageTeamB = $data['imageNameTeamB'];
                                $pickId = $data['pickId'];
                                

                                $MedalA = 'nomedal';
                                $MedalB = 'nomedal';
                                if (strcmp($PicksResult, 'Team A wins') == 0) {
                                    $MedalA = 'goldmedal';
                                } else if (strcmp($PicksResult, 'Team B wins') == 0) {
                                    $MedalB = 'goldmedal';
                                }
                                ?> 
                                <li>
                                    <div class="divMatchGroup">
                                        <table>
                                            <tr>
                                                <td>
                                                    <div class="divTeam" id="Round_<?php echo $RoundNr; ?>_Team_A_pickId_<?php echo $pickId; ?>">
                                                        <img src="<?php echo URL ?>public/image/flags/<?php echo $ImageTeamA ?>" alt=""/>
                                                        <img 
                                                            <?php if ($SetPicksEnabled) { ?>
                                                            id="idPickSymbol_A_<?php echo $pickId; ?>"
                                                            <?php } ?> src="<?php echo URL ?>public/image/<?php echo $MedalA ?>.png" alt=""/>                                                            <?php echo $DisplayNameTeamA; ?>
                                                    </div>
                                                </td>
                                                <td>VS</td>
                                                <td style="text-align: right;">
                                                    <div class="divTeam" id="Round_<?php echo $RoundNr; ?>_Team_B_pickId_<?php echo $pickId; ?>">
                                                        <?php echo $DisplayNameTeamB ?> 
                                                        <img 
                                                            <?php if ($SetPicksEnabled) { ?>
                                                            id="idPickSymbol_B_<?php echo $pickId; ?>" 
                                                            <?php } ?> src="<?php echo URL ?>public/image/<?php echo $MedalB ?>.png" alt=""/>
                                                        <img src="<?php echo URL ?>public/image/flags/<?php echo $ImageTeamB ?>" alt=""/>

                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </li>
                                <?php
                            }
                            ?>
                        </ul>
                    </td>
            </table>
        </div> 
        <?php
    }
    ?>
</div> 
</div> 
